//高频的组件加载为全局组件
import type { App } from 'vue'
// --------------- 全局组件
import SvgIcon from '@/components/SvgIcon/SvgIcon.vue'
import myImg from '@/components/myImg/myImg.vue'
import attributeCateSelect from '@/components/attributeCateSelect/attributeCateSelect.vue'

const allGloadblComponent = { SvgIcon, myImg, attributeCateSelect } as const

// // icon图标引入如果您正在使用CDN引入，请删除下面一行。
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// console.log(allGloadblComponent)

// 类型推断结果: { name: string }
// as const 类型推断结果: { readonly name: "SvgIcon" }
export default {
  install(app: App) {
    // console.log(Object.entries(allGloadblComponent))
    Object.entries(allGloadblComponent).forEach(([name, component]) => {
      // app.component(key, allGloadblComponent[key])
      app.component(name, component)
    })

    // icon图标引入
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  },
}
